<template>
	<view>
		<scroll-view scroll-y>
			<uni-card :shadow="false" 
					v-for="(it, index) in booksList" :key="index">
				<view style="uni-flex uni-column"  @click="onClickBackPublish" :data-index="index">
					<view style="font-size:12pt;color:#000;padding:10rpx 0;">
						<text>{{it.shopName}} {{it.address}}</text>
					</view>
					<view style="font-size:10pt;padding:10rpx 0;">
						<text>{{it.linkman}}</text>
						<text style="padding-left:20rpx;">{{it.phone}}</text>
					</view>
				</view>
			</uni-card>
		</scroll-view>
	</view>
</template>

<script>
	import { getBooksList } from '@/util/express_api.js'
	export default {
		data() {
			return {
				addressType: '',
				booksList: [
					{
						shopId: '',
						shopName: '',
						address: '',
						linkman: '',
						phone: ''
					}
				]
			}
		},
		onLoad(options) {
			var that = this;
			
			that.addressType = options.addressType;
			
			var userInfo = uni.getStorageSync('userInfo');
			if (userInfo != null && userInfo != '') {
				getBooksList({
					userId: userInfo.userId
				}).then(data => {
					that.booksList = data;
				});
			}
				
		},
		methods: {
			onClickBackPublish(e) {
				var that = this;
				var books = that.booksList[e.currentTarget.dataset.index];
				books.addressType = that.addressType;
				uni.$emit('returnData',{books: books});
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style>

</style>
